/* Standard includes */
#include <stdio.h>
#include <string.h>

/* LwIP includes */
#include "lwip/tcpip.h"
#include "lwip/api.h"

/* Scheduler includes */
#include "cmsis_os.h"

#include "stm324xg_eval.h"
#include "app_ethernet.h"

int SSL_Client();
int SSL_Server();
int mqtt_client();

/**
  * @brief  SSL Client Thread
  * @param  argument not used
  * @retval None
  */
void SSLClientThread(void const* argument)
{
    for (;;)
    {
        /* Delete the Init Thread */
        SSL_Client();

        STM_EVAL_LEDToggle(LED2);

        osDelay(2000);
    }
}

/**
  * @brief  SSL Server Thread
  * @param  argument not used
  * @retval None
  */
void SSLServerThread(void const* argument)
{
    for (;;)
    {
        /* Delete the Init Thread */
        if (SSL_Server())
        {
            STM_EVAL_LEDToggle(LED2);
        }
        osThreadTerminate(NULL);
    }
}


/**
  * @brief  SSL Client Thread
  * @param  argument not used
  * @retval None
  */
void IOTThread(void const* argument)
{
    for (;;)
    {
        if (DHCP_state == DHCP_ADDRESS_ASSIGNED)
        {
            osDelay(1000);
            mqtt_client();
            osDelay(1000);
            /* Delete the Init Thread */

            osThreadTerminate(NULL);
        }
        STM_EVAL_LEDToggle(LED2);
        osDelay(1000);
    }
}

